'use client';

import React, { useState, useEffect } from 'react';
import { getRecruitmentAnnouncementsPaginated } from '@/lib/recruitment';
import { getArticlesByType } from '@/lib/articles';
import { useRouter } from 'next/navigation';
import Image from 'next/image';
import { 
  MdBusinessCenter, // 管理岗位图标
  MdSchool,        // 教师岗位图标
  MdPeople,        // 其他岗位图标
  MdPersonAdd,     // 报名
  MdFactCheck,     // 资格审查
  MdQuiz,          // 考试考核
  MdLocalHospital, // 体检
  MdCheckCircle,   // 录用
  MdLogin,         // 登录按钮图标
  MdSearch,        // 搜索图标
  MdFileDownload,  // 下载图标
  MdMenu
} from 'react-icons/md';
import Cookies from 'js-cookie';
import { mobileNavStyles } from '@/styles/mobileNav';
import { MENU_MAPPING } from '@/constants/menuMapping';
import dayjs from 'dayjs';
import { Box, Button } from '@mui/material';
import NavigateNextIcon from '@mui/icons-material/NavigateNext';

// 添加自定义 Hook
const useScrollAnimation = () => {
  useEffect(() => {
    const observer = new IntersectionObserver(
      (entries) => {
        entries.forEach(entry => {
          if (entry.isIntersecting) {
            entry.target.classList.add('animate-in');
          }
        });
      },
      {
        threshold: 0.1 // 当元素10%进入视口时触发
      }
    );

    // 获取所有需要动画的元素
    const sections = document.querySelectorAll('.animate-section');
    sections.forEach(section => observer.observe(section));

    return () => observer.disconnect();
  }, []);
};

const PublicRecruitmentPage = () => {
  const router = useRouter();
  const [announcements, setAnnouncements] = useState([]);
  const [loading, setLoading] = useState(true);
  const [isLoggedIn, setIsLoggedIn] = useState(false);
  const [isSidebarOpen, setIsSidebarOpen] = useState(false);
  const [isNavHovered, setIsNavHovered] = useState(false);
  const [isScrolled, setIsScrolled] = useState(false);
  const [activeMenu, setActiveMenu] = useState('5');

  useEffect(() => {
    loadAnnouncements();
  }, []);

  // 检查登录状态
  useEffect(() => {
    const checkLoginStatus = () => {
      const token = Cookies.get('token');
      const isLogged = !!token;
      setIsLoggedIn(isLogged);
      console.log('登录状态检查:', {
        token: token,
        isLoggedIn: isLogged
      });
    };
    
    checkLoginStatus();
  }, []);

  // 添加滚动监听
  useEffect(() => {
    const handleScroll = () => {
      const scrollPosition = window.scrollY;
      setIsScrolled(scrollPosition > 100); // 当滚动超过100px时触发
    };

    window.addEventListener('scroll', handleScroll);
    return () => window.removeEventListener('scroll', handleScroll);
  }, []);

  const loadAnnouncements = async () => {
    try {
      const response = await getArticlesByType(1); // 使用适当的类型ID
      if (response.data?.code === 1) {
        setAnnouncements(response.data.data);
      } else {
        console.error('获取公告失败:', response.data);
      }
    } catch (error: any) {
      console.error('获取招聘公告失败:', {
        message: error.message,
        response: error.response?.data,
        status: error.response?.status
      });
    } finally {
      setLoading(false);
    }
  };

  // 添加卡片翻转处理函数
  const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
    const card = e.currentTarget;
    const rect = card.getBoundingClientRect();
    const x = e.clientX - rect.left; // 鼠标在卡片上的X坐标
    const y = e.clientY - rect.top;  // 鼠标在卡片上的Y坐标
    
    const centerX = rect.width / 2;
    const centerY = rect.height / 2;
    
    // 计算旋转角度（最大15度）
    const rotateX = -((y - centerY) / centerY) * 15;
    const rotateY = ((x - centerX) / centerX) * 15;
    
    card.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale3d(1.05, 1.05, 1.05)`;
  };

  const handleMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => {
    const card = e.currentTarget;
    card.style.transform = 'perspective(1000px) rotateX(0) rotateY(0) scale3d(1, 1, 1)';
  };

  // 添加动画控制
  useEffect(() => {
    const animateTimeline = () => {
      const items = document.querySelectorAll('.timeline-point');
      let currentIndex = 0;

      const animate = () => {
        // 重置所有点的状态
        items.forEach(item => {
          item.classList.remove('active');
        });

        // 激活当前点
        if (currentIndex < items.length) {
          items[currentIndex].classList.add('active');
          currentIndex++;
        } else {
          currentIndex = 0; // 重新开始
        }
      };

      // 每2秒切换一次
      const interval = setInterval(animate, 2000);
      animate(); // 立即开始第一次动画

      return () => clearInterval(interval);
    };

    animateTimeline();
  }, []);

  // 处理按钮点击
  const handleButtonClick = (e: React.MouseEvent<HTMLButtonElement>) => {
    e.preventDefault();
    const token = Cookies.get('token');
    if (token) {
      router.push('/dashboard');
    } else {
      router.push('/login');
    }
  };

  // 使用自定义 Hook
  useScrollAnimation();

  // 修改路由映射部分
  const menuRoutes = {
    '5': '/public/recruitment/announcements?menuId=5', // 人才招聘
    '6': '/public/recruitment/announcements?menuId=6', // 其他公告
    // ... 其他路由
  };

  // 修改点击处理函数
  const handleMenuClick = (menuId: string) => {
    const route = menuRoutes[menuId];
    if (route) {
      router.push(route);
    }
  };

  // 修改菜单渲染部分
  <Box sx={{ display: 'flex', gap: 2, mb: 4 }}>
    <Button
      variant={activeMenu === '5' ? 'contained' : 'outlined'}
      onClick={() => handleMenuClick('5')}
      sx={{
        color: activeMenu === '5' ? '#fff' : '#666',
        bgcolor: activeMenu === '5' ? '#c1272d' : 'transparent',
        '&:hover': {
          bgcolor: activeMenu === '5' ? '#a61f24' : 'rgba(193, 39, 45, 0.04)',
          color: activeMenu === '5' ? '#fff' : '#c1272d'
        }
      }}
    >
      人才招聘
    </Button>
    <Button
      variant={activeMenu === '6' ? 'contained' : 'outlined'}
      onClick={() => handleMenuClick('6')}
      sx={{
        color: activeMenu === '6' ? '#fff' : '#666',
        bgcolor: activeMenu === '6' ? '#c1272d' : 'transparent',
        '&:hover': {
          bgcolor: activeMenu === '6' ? '#a61f24' : 'rgba(193, 39, 45, 0.04)',
          color: activeMenu === '6' ? '#fff' : '#c1272d'
        }
      }}
    >
      其他公告
    </Button>
  </Box>

  // 修改链接生成函数
  const generateMenuLink = (menuId: number) => {
    const menuIdString = menuId.toString();
    const menuItem = MENU_MAPPING[menuIdString];
    if (menuItem && menuItem.path) {
      return `${menuItem.path}?menuId=${menuIdString}`;
    }
    return '/public/recruitment/announcements'; // 返回一个默认路径
  };

  return (
    <div className={`container ${mobileNavStyles.mobileNav} ${mobileNavStyles.sidebar} ${mobileNavStyles.overlay}`}>
      <nav 
        className={`top-nav ${isScrolled ? 'scrolled' : ''}`}
        onMouseEnter={() => setIsNavHovered(true)}
        onMouseLeave={() => setIsNavHovered(false)}
      >
        <div className="nav-content">
          <div className="left-section">
            <div className="logo">
              <Image 
                src={window.innerWidth > 768 ? (isNavHovered || isScrolled ? "/images/logo_xg.png" : "/images/logo.png") : "/images/logo.png"}
                alt="校徽" 
                width={160} 
                height={100} 
                style={{ 
                  width: 'auto', 
                  height: 'auto', 
                  maxHeight: '100%', 
                  objectFit: 'contain',
                  marginTop: '-8px',
                  transition: 'opacity 0.3s ease'
                }}
              />
            </div>
          </div>
          <div className="nav-links">
            <div className="nav-links-center">
              <a href="https://www.guit.edu.cn" className="school-home">学校首页</a>
              <a href="/public/recruitment">部门首页</a>
              <a href={generateMenuLink(1)}>部门介绍</a>
              <div className="dropdown">
                <a href={generateMenuLink(2)} className="dropdown-trigger">
                  师德师风
                  <span className="arrow-down"></span>
                </a>
                <div className="dropdown-menu">
                  <a href={generateMenuLink(2)}>师德师风</a>
                  <a href={generateMenuLink(3)}>教师发展</a>
                  <a href={generateMenuLink(4)}>师德师风举报</a>
                </div>
              </div>
              <a href={generateMenuLink(5)}>人才招聘</a>
              <a href={generateMenuLink(6)}>职称评审</a>
              <a href={generateMenuLink(7)}>资料下载</a>
              <a href={generateMenuLink(8)}>办事流程</a>
            </div>
          </div>
          <div className="right-section">
            <div className="search-box">
              <input 
                type="text" 
                placeholder="搜索职位、公告..." 
                className="search-input"
              />
              <MdSearch size={20} className="search-icon" />
            </div>
            <div className="login-wrapper">
              <button onClick={handleButtonClick} className="login-button">
                <MdLogin size={20} />
                <span>{isLoggedIn ? '返回系统' : '登录系统'}</span>
              </button>
            </div>
          </div>
          <button 
            className={`mobile-menu-button ${isSidebarOpen ? 'open' : ''}`}
            onClick={() => setIsSidebarOpen(!isSidebarOpen)}
          >
            <span></span>
            <span></span>
            <span></span>
          </button>
        </div>
      </nav>

      <div className="banner">
        {/* 移除所有文字和按钮内容 */}
      </div>

      <main>
        <section className="quick-links animate-section">
          <h2 className="section-title">快速通道</h2>
          <div className="quick-links-grid">
            <div 
              className="quick-link-card management"
              onMouseMove={handleMouseMove}
              onMouseLeave={handleMouseLeave}
              onClick={() => router.push('/public/recruitment/announcements?menuId=5')}
            >
              <div className="icon-wrapper">
                <MdBusinessCenter size={60} />
              </div>
              <h3>管理岗位<br/>招聘</h3>
              <button className="apply-now">立即申请</button>
            </div>

            <div 
              className="quick-link-card teacher"
              onMouseMove={handleMouseMove}
              onMouseLeave={handleMouseLeave}
              onClick={() => router.push('/public/recruitment/announcements?menuId=5')}
            >
              <div className="icon-wrapper">
                <MdSchool size={60} />
              </div>
              <h3>专任教师<br/>招聘</h3>
              <button className="apply-now">立即申请</button>
            </div>

            <div 
              className="quick-link-card other"
              onMouseMove={handleMouseMove}
              onMouseLeave={handleMouseLeave}
              onClick={() => router.push('/public/recruitment/announcements?menuId=5')}
            >
              <div className="icon-wrapper">
                <MdPeople size={60} />
              </div>
              <h3>其他岗位<br/>招聘</h3>
              <button className="apply-now">立即申请</button>
            </div>
          </div>
        </section>

        <section className="recruitment-guide animate-section">
          <h2 className="section-title">招聘指南</h2>
          <div className="guide-container">
            {/* 左侧新闻区域 */}
            <div className="news-section">
              {/* 招聘动态 */}
              <div className="news-block">
                <div className="block-header">
                  <h3 style={{ 
                    color: '#c1272d',  // 改为红色
                    fontSize: '22px',  // 增大字号
                    fontWeight: 600    // 加粗
                  }}>
                    招聘动态
                  </h3>
                  <a href="/public/recruitment/announcements?menuId=5" className="view-more">
                    查看更多
                  </a>
                </div>
                <div className="news-list">
                  {announcements.map((announcement: any) => (
                    <div key={announcement.id} className="news-item">
                      <div className="date-block">
                        <span className="day" style={{ 
                          color: '#c1272d',  // 日期数字改为红色
                          fontSize: '24px',
                          fontWeight: 700
                        }}>
                          {dayjs(announcement.publishDate).format('DD')}
                        </span>
                        <span className="month">
                          {dayjs(announcement.publishDate).format('MM月')}
                        </span>
                      </div>
                      <a href={`/announcements/${announcement.id}`} className="title" style={{
                        color: '#333',       // 标题默认颜色加深
                        fontSize: '16px',    // 增大字号
                        fontWeight: 500,     // 加粗
                        textDecoration: 'none',
                        transition: 'color 0.3s ease'
                      }}>
                        {announcement.title}
                      </a>
                    </div>
                  ))}
                </div>
              </div>

              {/* 通知公告 */}
              <div className="news-block">
                <div className="block-header">
                  <h3>通知公告</h3>
                  <a href="#" className="view-more">更多 &gt;</a>
                </div>
                <div className="news-list">
                  <div className="news-item">
                    <div className="date-block">
                      <span className="day">08</span>
                      <span className="month">01月</span>
                    </div>
                    <a href="#" className="title">关于做好全国高校教师管理信息系统2024年度秋季学期信息更新的通知</a>
                  </div>
                  <div className="news-item">
                    <div className="date-block">
                      <span className="day">01</span>
                      <span className="month">01月</span>
                    </div>
                    <a href="#" className="title">中层管理人员任职前公示</a>
                  </div>
                </div>
              </div>
            </div>

            {/* 右侧按钮组 */}
            <div className="guide-buttons">
              <a href="#" className="guide-button campus">
                <div className="button-icon">
                  <MdSchool />
                </div>
                <div className="button-content">
                  <span className="button-title">校招行程</span>
                  <span className="button-desc">了解校园招聘流程和时间安排</span>
                </div>
              </a>
              <a href="#" className="guide-button download">
                <div className="button-icon">
                  <MdFileDownload />
                </div>
                <div className="button-content">
                  <span className="button-title">资料下载</span>
                  <span className="button-desc">下载招聘相关文件和表格</span>
                </div>
              </a>
              <a href="#" className="guide-button ethics">
                <div className="button-icon">
                  <MdPeople />
                </div>
                <div className="button-content">
                  <span className="button-title">师德师风</span>
                  <span className="button-desc">了解教师职业道德规范</span>
                </div>
              </a>
            </div>
          </div>
        </section>

        <section className="recruitment-process">
          <h2 className="section-title">招聘流程</h2>
          <div className="timeline">
            <div className="arrow-start">
              <div className="arrow-head"></div>
            </div>
            <div className="timeline-item">
              <div className="timeline-point-wrapper">
                <div className="timeline-point">
                  <MdPersonAdd size={16} />
                </div>
              </div>
              <div className="timeline-content">报名</div>
            </div>
            <div className="timeline-item">
              <div className="timeline-point-wrapper">
                <div className="timeline-point">
                  <MdFactCheck size={16} />
                </div>
              </div>
              <div className="timeline-content">资格审查</div>
            </div>
            <div className="timeline-item">
              <div className="timeline-point-wrapper">
                <div className="timeline-point">
                  <MdQuiz size={16} />
                </div>
              </div>
              <div className="timeline-content">考试与考核</div>
            </div>
            <div className="timeline-item">
              <div className="timeline-point-wrapper">
                <div className="timeline-point">
                  <MdSchool size={16} />
                </div>
              </div>
              <div className="timeline-content">学校研究决定</div>
            </div>
            <div className="timeline-item">
              <div className="timeline-point-wrapper">
                <div className="timeline-point">
                  <MdLocalHospital size={16} />
                </div>
              </div>
              <div className="timeline-content">体检</div>
            </div>
            <div className="timeline-item">
              <div className="timeline-point-wrapper">
                <div className="timeline-point">
                  <MdCheckCircle size={16} />
                </div>
              </div>
              <div className="timeline-content">录用</div>
            </div>
          </div>
        </section>
      </main>

      <footer className="site-footer">
        <div className="footer-content">
          <div className="copyright">
            © 2024 桂林信息科技学院人事处. All rights reserved.
          </div>
        </div>
      </footer>

      <div className={`sidebar-overlay ${isSidebarOpen ? 'visible' : ''}`} onClick={() => setIsSidebarOpen(false)} />
      <div className={`sidebar ${isSidebarOpen ? 'open' : ''}`}>
        <button 
          className="close-button"
          onClick={() => setIsSidebarOpen(false)}
        >
          <span></span>
          <span></span>
        </button>
        <div className="sidebar-top">
          <div className="search-box">
            <input type="text" placeholder="搜索职位、公告..." />
            <MdSearch size={20} className="search-icon" />
          </div>
          <button onClick={handleButtonClick} className="login-button">
            <MdLogin size={20} />
            <span>{isLoggedIn ? '返回系统' : '登录系统'}</span>
          </button>
        </div>
        <div className="sidebar-content">
          <div className="sidebar-menu">
            <a href="https://www.guit.edu.cn">学校首页</a>
            <a href="/public/recruitment">部门首页</a>
            {Object.entries(MENU_MAPPING).map(([key, value]) => {
              if (!value || !value.path) return null;
              
              if (value.title === '师德师风') {
                return (
                  <div key={key} className="dropdown-items">
                    <a href={`${value.path}?menuId=${key}`}>师德师风</a>
                    {MENU_MAPPING['3']?.path && (
                      <a href={`${MENU_MAPPING['3'].path}?menuId=3`}>教师发展</a>
                    )}
                    {MENU_MAPPING['4']?.path && (
                      <a href={`${MENU_MAPPING['4'].path}?menuId=4`}>师德师风举报</a>
                    )}
                  </div>
                );
              }
              
              if (!['3', '4'].includes(key)) {
                return (
                  <a key={key} href={`${value.path}?menuId=${key}`}>
                    {value.title}
                  </a>
                );
              }
              
              return null;
            })}
          </div>
        </div>
      </div>

      <style jsx>{`
        /* ====== 容器基础样式 ====== */
        .container {
          min-height: 100vh;
          background: #fff;
          margin: 0;
          padding: 0;
          overflow-x: hidden;
        }

        /* ====== 导航栏样式 ====== */
        .top-nav {
          position: fixed;
          width: 100%;
          top: 0;
          z-index: 1000;
          background: transparent;
          transition: background 0.3s;
        }

        /* 移动端样式 */
        @media (max-width: 768px) {
          .top-nav {
            background: #001529; /* 移动端固定背景色 */
          }

          .top-nav::before {
            display: none; /* 移动端禁用动画效果 */
          }

          /* 移动端禁用所有hover和scroll效果 */
          .top-nav:hover::before,
          .top-nav.scrolled::before {
            height: 0;
          }

          /* 移动端固定logo样式 */
          .logo img {
            opacity: 1 !important;
            transition: none !important;
          }
        }

        .top-nav::before {
          content: '';
          position: absolute;
          bottom: 0;
          left: 0;
          width: 100%;
          height: 0;
          background: #001529;
          transition: height 0.3s ease;
          z-index: -1;
        }

        .top-nav:hover::before,
        .top-nav.scrolled::before {
          height: 100%;
        }

        /* 确保导航内容在动画层之上 */
        .nav-content {
          position: relative;
          z-index: 1;
        }

        /* 导航链接颜色过渡 */
        .nav-links a {
          color: #fff;
          transition: color 0.3s ease;
        }

        .nav-content {
          max-width: 1600px;
          margin: 0 auto;
          padding: 0;
          display: flex;
          align-items: center;
          height: 100px;
        }

        /* ====== Logo区域样式 ====== */
        .left-section {
          position: absolute;
          left: -80px;
          top: -18px;
          z-index: 1000;
        }

        .logo {
          display: flex;
          align-items: center;
          width: 160px;
          height: 100px;
          padding: 4px 0;
        }

        .logo > :global(img) {
          width: auto !important;
          height: auto !important;
          max-height: 100% !important;
          object-fit: contain !important;
          margin-top: -8px;
        }

        /* ====== 导航链接样式 ====== */
        .nav-links {
          position: absolute;
          left: 50%;
          transform: translate(-50%, -36%);
          display: flex;
          justify-content: center;
          margin-left: 80px;
        }

        .nav-links-center {
          display: flex;
          align-items: center;
          gap: 36px;
          height: 100%;
          margin-right: 360px;
        }

        .nav-links-center a {
          color: #fff;
          text-decoration: none;
          font-size: 16px;
          padding: 8px 24px;
          margin: 0 -12px;
          height: 100%;
          display: flex;
          align-items: center;
          white-space: nowrap;
          position: relative;
          transition: all 0.3s ease;
        }

        .nav-links-center a:hover {
          background: linear-gradient(
            45deg,
            rgba(255, 255, 255, 0.1),
            rgba(255, 255, 255, 0.2)
          );
          transform: translateY(-2px);
          text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
          border-radius: 6px;
        }

        .nav-links-center a::after {
          content: '';
          position: absolute;
          bottom: -6px;
          left: 50%;
          width: 0;
          height: 2px;
          background: #1890ff;
          transition: all 0.3s ease;
          transform: translateX(-50%);
        }

        .nav-links-center a:hover::after {
          width: 80%;
        }

        .right-section {
          position: absolute;
          right: -20px;
          top: 35%;
          display: flex;
          align-items: center;
          gap: 32px;
          min-width: 320px;
          transform: translateY(-50%);
        }

        .search-box {
          display: flex;
          align-items: center;
          background: rgba(255, 255, 255, 0.1);
          border-radius: 20px;
          padding: 6px 16px;
          width: 180px;
          margin-left: 16px;
        }

        .search-input {
          background: transparent;
          border: none;
          color: #fff;
          padding: 4px 8px;
          width: 100%;
          outline: none;
          font-size: 14px;
        }

        .search-input::placeholder {
          color: rgba(255, 255, 255, 0.6);
        }

        .search-icon {
          color: rgba(255, 255, 255, 0.8);
          transition: all 0.3s ease;
        }

        .login-wrapper {
          position: relative;
        }

        .login-button {
          position: relative;
          display: flex;
          align-items: center;
          gap: 8px;
          padding: 8px 20px;
          border-radius: 24px;
          background: rgba(255, 255, 255, 0.1);
          color: #fff;
          text-decoration: none;
          border: 1px solid rgba(255, 255, 255, 0.2);
          font-size: 14px;
          font-weight: 500;
          letter-spacing: 0.5px;
          overflow: hidden;
          cursor: pointer;
          user-select: none;
          outline: none;
          width: auto;
        }

        .login-button::after {
          content: '';
          display: block;
          position: absolute;
          width: 100%;
          height: 100%;
          top: 0;
          left: 0;
          pointer-events: none;
          background-image: radial-gradient(circle, rgba(255, 255, 255, 0.3) 10%, transparent 10.01%);
          background-repeat: no-repeat;
          background-position: 50%;
          transform: scale(10, 10);
          opacity: 0;
          transition: transform .5s, opacity 1s;
        }

        .login-button:active::after {
          transform: scale(0, 0);
          opacity: .5;
          transition: 0s;
          background-image: radial-gradient(circle, rgba(255, 255, 255, 0.4) 10%, transparent 10.01%);
        }

        .login-button:hover {
          background: rgba(255, 255, 255, 0.15);
        }

        .login-button svg,
        .login-button span {
          position: relative;
          z-index: 1;
          pointer-events: none;
        }

        .mobile-menu-button {
          display: none;
        }

        @media (max-width: 1024px) {
          .nav-content {
            justify-content: center;
            padding: 0 16px;
            position: relative;
            height: 64px;
          }

          .left-section {
            position: static;
            left: auto;
            top: auto;
            transform: none;
          }

          .logo {
            position: absolute;
            left: 30%;
            top: 50%;
            transform: translate(-50%, -50%);
            z-index: 1;
          }

          .logo img {
            height: 50px;
            width: auto;
            margin-top: 0;
          }

          .mobile-menu-button {
            display: flex;
            position: absolute;
            right: 16px;
            top: 28px;
            width: 28px;
            height: 18px;
            padding: 0;
            background: none;
            border: none;
            cursor: pointer;
            z-index: 1001;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
          }

          .mobile-menu-button span {
            display: block;
            width: 24px;
            height: 2px;
            background-color: #fff;
            transition: all 0.3s ease;
            border-radius: 2px;
          }

          .mobile-menu-button.open {
            position: fixed;
            right: 16px;
            top: 28px;
          }

          .sidebar {
            right: -320px;
            width: 300px;
          }

          .sidebar.open {
            right: 0;
          }

          .nav-links,
          .right-section {
            display: none;
          }

          .quick-links-grid {
            display: flex;
            flex-direction: column;
            gap: 20px;
            padding: 0 16px;
            max-width: 100%;
          }

          .quick-link-card {
            margin: 0;
            padding: 30px 20px;
            width: auto;
          }

          .guide-container {
            display: flex;
            flex-direction: column;
            gap: 24px;
            padding: 0 16px;
          }

          .news-section {
            order: 2;
            width: 100%;
          }

          .news-block {
            margin-bottom: 20px;
          }

          .block-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 0;
            margin-bottom: 16px;
          }

          .view-more {
            padding: 4px 12px;
            white-space: nowrap;
            color: #666;
            text-decoration: none;
            transition: color 0.3s;
            
            &:hover {
              color: #1890ff;
            }
          }

          .news-list {
            width: 100%;
          }

          .news-item {
            width: 100%;
            padding: 12px 0;
            border-bottom: 1px solid #f0f0f0;

            .title {
              width: calc(100% - 100px); // 留出日期的空间
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            }
          }

          .guide-buttons {
            order: 1;
            display: flex;
            flex-direction: column;
            gap: 16px;
            width: 100%;
          }

          .guide-button {
            width: 100%;
            padding: 16px;
          }

          .banner {
            height: auto;
            min-height: 300px;
            padding: 60px 20px;
          }

          .banner-content {
            padding: 0 16px;
            width: 100%;
          }

          main {
            padding: 40px 16px;
            width: 100%;
            max-width: 100%;
            overflow-x: hidden;
          }

          .section-title {
            font-size: 24px;
            margin-bottom: 30px;
            text-align: center;
            width: 90%;
          }
        }

        @media (max-width: 480px) {
          .banner h1 {
            font-size: 1.5em;
          }

          .banner-title {
            font-size: 2em;
          }

          .quick-link-card {
            padding: 24px 16px;
          }

          .icon-wrapper {
            width: 80px;
            height: 80px;
          }

          .news-item {
            flex-direction: column;
            gap: 8px;

            .date-block {
              margin-bottom: 8px;
            }

            .title {
              width: 100%;
            }
          }
        }

        /* ====== Banner样式 ====== */
        .banner {
          width: 100%;
          margin-top: -64px; /* 负边距抵消导航栏的高度 */
          background-image: url('/images/banner.jpg');
          background-position: center;
          background-repeat: no-repeat;
          background-size: 100% auto;
          height: auto;
          position: relative;
        }

        .banner::before {
          content: '';
          display: block;
          padding-top: calc(33.33% * 1.5);
        }

        .section-title {
          font-size: 28px;
          font-weight: bold;
          margin-bottom: 40px;
          text-align: center;
          width: 100%;
          max-width: 1400px;
          margin-left: auto;
          margin-right: auto;
          padding: 0 20px;
          color: #000;
          position: relative;
        }

        .section-title::after {
          content: '';
          position: absolute;
          bottom: -10px;
          left: 50%;
          transform: translateX(-50%);
          width: 60px;
          height: 3px;
          background: linear-gradient(90deg, #1890ff, #69c0ff);
          border-radius: 2px;
        }

        .quick-links {
          padding: 60px 0;
          background: #fff;
          margin: 0;
          border-top: none;
        }

        .quick-links-grid {
          display: grid;
          grid-template-columns: repeat(3, 1fr);
          gap: 40px;
          max-width: 1400px;
          margin: 0 auto;
          padding: 0 20px;
        }

        .quick-link-card {
          padding: 40px;
          margin: 10px;
          border-radius: 16px;
          text-align: center;
          cursor: pointer;
          display: flex;
          flex-direction: column;
          align-items: center;
          gap: 20px;
          transition: all 0.3s ease;
          transform-style: preserve-3d;
          position: relative;
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        .quick-link-card.management {
          background: linear-gradient(135deg, #fff5f5 0%, #ffe0e0 100%);
        }

        .quick-link-card.teacher {
          background: linear-gradient(135deg, #f0f7ff 0%, #e6f3ff 100%);
        }

        .quick-link-card.other {
          background: linear-gradient(135deg, #fff7e6 0%, #ffe7ba 100%);
        }

        .icon-wrapper {
          width: 100px;
          height: 100px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 50%;
          margin-bottom: 16px;
          transition: all 0.3s ease;
        }

        .management .icon-wrapper {
          background: rgba(197, 31, 58, 0.1);
          color: #c51f3a;
        }

        .teacher .icon-wrapper {
          background: rgba(24, 144, 255, 0.1);
          color: #1890ff;
        }

        .other .icon-wrapper {
          background: rgba(255, 122, 0, 0.1);
          color: #ff7a00;
        }

        .quick-link-card h3 {
          font-size: 20px;
          color: #333;
          margin: 0;
          line-height: 1.5;
        }

        .apply-now {
          padding: 10px 32px;
          border-radius: 20px;
          border: none;
          color: white;
          font-size: 16px;
          cursor: pointer;
          transition: all 0.3s ease;
          margin-top: 16px;
        }

        .management .apply-now {
          background: #c51f3a;
        }

        .teacher .apply-now {
          background: #1890ff;
        }

        .other .apply-now {
          background: #ff7a00;
        }

        .apply-now:hover {
          transform: translateY(-2px);
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }

        .management .apply-now:hover {
          background: #d4293f;
        }

        .teacher .apply-now:hover {
          background: #40a9ff;
        }

        .other .apply-now:hover {
          background: #ff9933;
        }

        .quick-link-card:hover {
          transform: translateY(-5px);
          box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
        }

        .quick-link-card:hover .icon-wrapper {
          transform: scale(1.1);
        }

        .recruitment-process {
          padding: 60px 20px;
          background: #fff;
          position: relative;
          overflow: hidden;
        }

        .timeline {
          max-width: 1200px;
          margin: 40px auto;
          display: flex;
          justify-content: space-between;
          align-items: center;
          position: relative;
          padding: 20px 0;
        }

        .timeline::before {
          content: '';
          position: absolute;
          top: 50%;
          left: 0;
          right: 0;
          height: 2px;
          background: repeating-linear-gradient(
            90deg,
            #c51f3a 0px,
            #c51f3a 8px,
            transparent 8px,
            transparent 16px
          );
          transform: translateY(-50%);
          animation: flowLine 1s linear infinite;
        }

        @keyframes flowLine {
          0% {
            background-position: 0 0;
          }
          100% {
            background-position: 16px 0;
          }
        }

        .timeline-point-wrapper {
          width: 64px;
          height: 64px;
          border: 2px dashed #c51f3a;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          margin-bottom: 15px;
          position: relative;
          animation: rotateDashed 8s linear infinite;
        }

        .timeline-point-wrapper::before {
          content: '';
          position: absolute;
          top: -4px;
          left: -4px;
          right: -4px;
          bottom: -4px;
          border: 2px dashed #c51f3a;
          border-radius: 50%;
          opacity: 0.5;
          animation: rotateDashedReverse 6s linear infinite;
        }

        @keyframes rotateDashed {
          from {
            transform: rotate(0deg);
          }
          to {
            transform: rotate(360deg);
          }
        }

        @keyframes rotateDashedReverse {
          from {
            transform: rotate(360deg);
          }
          to {
            transform: rotate(0deg);
          }
        }

        .timeline-point {
          width: 40px;
          height: 40px;
          background: #fff;
          border: 3px solid #c51f3a;
          border-radius: 50%;
          position: relative;
          display: flex;
          align-items: center;
          justify-content: center;
          transition: all 0.5s ease;
          z-index: 1;
        }

        .timeline-point.active {
          transform: scale(1.8);
          background: #fff;
        }

        .timeline-point.active + .timeline-point-wrapper {
          transform: scale(1.4);
          border-color: #c51f3a;
        }

        .timeline-point.active + .timeline-point-wrapper::before {
          transform: scale(1.3);
          border-color: #c51f3a;
        }

        .timeline-point :global(svg) {
          color: #c51f3a;
          transition: all 0.5s ease;
          font-size: 20px;
        }

        .timeline-point.active :global(svg) {
          transform: scale(1.2);
          color: #c51f3a;
        }

        .timeline-content {
          color: #333;
          font-size: 1.1em;
          font-weight: 500;
          text-align: center;
          transition: all 0.5s ease;
        }

        .timeline-item .timeline-point.active + .timeline-content {
          transform: scale(1.1);
          color: #c51f3a;
          font-weight: bold;
        }

        @media (max-width: 768px) {
          .timeline {
            flex-direction: column;
            gap: 30px;
          }

          .timeline::before {
            width: 2px;
            height: 100%;
            left: 50%;
            top: 0;
            transform: translateX(-50%);
            background: repeating-linear-gradient(
              180deg,
              #c51f3a 0px,
              #c51f3a 8px,
              transparent 8px,
              transparent 16px
            );
            animation: flowLineVertical 1s linear infinite;
          }

          @keyframes flowLineVertical {
            0% {
              background-position: 0 0;
            }
            100% {
              background-position: 0 16px;
            }
          }
        }

        .arrow-start {
          position: absolute;
          left: -20px;
          top: 50%;
          transform: translateY(-50%);
          width: 20px;
          height: 20px;
          z-index: 2;
        }

        .arrow-head {
          width: 0;
          height: 0;
          border-top: 10px solid transparent;
          border-bottom: 10px solid transparent;
          border-left: 15px solid #c51f3a;
          position: relative;
          animation: arrowPulse 1s infinite;
        }

        @keyframes arrowPulse {
          0% {
            transform: translateX(0);
            opacity: 1;
          }
          50% {
            transform: translateX(5px);
            opacity: 0.6;
          }
          100% {
            transform: translateX(0);
            opacity: 1;
          }
        }

        @media (max-width: 768px) {
          .arrow-start {
            left: 50%;
            top: -20px;
            transform: translateX(-50%) rotate(90deg);
          }
        }

        .has-submenu {
          position: relative;
        }

        .submenu {
          position: absolute;
          top: 100%;
          left: 0;
          background: #fff;
          border-radius: 4px;
          padding: 4px 0;
          min-width: 120px;
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
          opacity: 0;
          visibility: hidden;
          transform: translateY(-5px);
          transition: all 0.2s ease;
          z-index: 1000;
        }

        .has-submenu:hover .submenu {
          opacity: 1;
          visibility: visible;
          transform: translateY(0);
        }

        .submenu a {
          color: #333 !important;
          padding: 8px 16px !important;
          height: auto !important;
          font-size: 14px;
          display: block;
        }

        .submenu a:hover {
          color: #1890ff !important;
          background: rgba(24, 144, 255, 0.1) !important;
        }

        .site-footer {
          background: rgba(147, 26, 29, 0.95);
          color: #fff;
          padding: 20px 0;
          text-align: center;
          margin-top: 60px;
        }

        .footer-content {
          max-width: 1200px;
          margin: 0 auto;
          padding: 0 20px;
        }

        .copyright {
          font-size: 14px;
          color: rgba(255, 255, 255, 0.8);
        }

        .recruitment-guide {
          padding: 60px 0;
          background: #f8f9fa;
        }

        .guide-container {
          max-width: 1400px;
          margin: 0 auto;
          display: grid;
          grid-template-columns: 1.3fr 1fr;
          gap: 40px;
          padding: 0 20px;
        }

        .news-section {
          display: grid;
          grid-template-columns: 1fr;
          gap: 30px;
        }

        .news-block {
          transform: scale(0.92);
          transform-origin: center top;
          background: #fff;
          border-radius: 12px;
          padding: 24px;
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
          margin-bottom: 30px; /* 补偿缩放后的间距 */
        }

        .block-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 20px;
          padding-bottom: 10px;
          border-bottom: 2px solid #f0f0f0;
        }

        .block-header h3 {
          font-size: 20px;
          color: #333;
          margin: 0;
        }

        .view-more {
          color: #666;
          text-decoration: none;
          transition: color 0.3s;
        }

        .view-more:hover {
          color: #c51f3a;
        }

        .news-list {
          display: flex;
          flex-direction: column;
          gap: 15px;
        }

        .news-item {
          display: flex;
          align-items: center;
          gap: 15px;
        }

        .date-block {
          display: flex;
          flex-direction: column;
          align-items: center;
          min-width: 60px;
        }

        .day {
          font-size: 24px;
          font-weight: bold;
          color: #c51f3a;
        }

        .month {
          font-size: 14px;
          color: #666;
        }

        .title {
          flex: 1;
          color: #333;
          text-decoration: none;
          transition: color 0.3s;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }

        .title:hover {
          color: #c1272d;
        }

        .guide-buttons {
          transform: scale(0.9);
          transform-origin: center top;
          width: 100%;
          display: flex;
          flex-direction: column;
          gap: 20px;
        }

        .guide-button {
          display: flex;
          align-items: center;
          gap: 20px;
          padding: 20px;
          border-radius: 12px;
          text-decoration: none;
          color: #fff;
          transition: all 0.3s ease;
          position: relative;
          overflow: hidden;
        }

        .guide-button::before {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          background: linear-gradient(45deg, rgba(255,255,255,0.1), rgba(255,255,255,0));
          transform: translateX(-100%);
          transition: transform 0.6s ease;
        }

        .guide-button:hover::before {
          transform: translateX(100%);
        }

        .guide-button.campus {
          background: linear-gradient(45deg, #722ed1, #9254de);
        }

        .guide-button.download {
          background: linear-gradient(45deg, #13c2c2, #36cfc9);
        }

        .guide-button.ethics {
          background: linear-gradient(45deg, #eb2f96, #f759ab);
        }

        .button-icon {
          background: rgba(255, 255, 255, 0.2);
          padding: 15px;
          border-radius: 12px;
          font-size: 24px;
          transition: transform 0.3s ease;
        }

        .guide-button:hover .button-icon {
          transform: scale(1.1) rotate(10deg);
        }

        .button-content {
          flex: 1;
        }

        .button-title {
          display: block;
          font-size: 20px;
          font-weight: bold;
          margin-bottom: 5px;
        }

        .button-desc {
          font-size: 14px;
          opacity: 0.9;
        }

        @media (max-width: 768px) {
          .guide-container {
            grid-template-columns: 1fr;
          }

          .news-section {
            grid-template-columns: 1fr;
          }

          .section-title {
            font-size: 24px;
            margin-bottom: 30px;
            width: 90%;
          }

          .guide-buttons {
            transform: scale(0.9);
            width: calc(100% - 32px); /* 减去两边的边距 */
            margin: 0 auto;
          }

          .news-block {
            transform: scale(0.92);
            width: calc(100% - 32px); /* 减去两边的边距 */
            margin: 0 auto 25px;
          }

          /* 确保内容不会超出边距 */
          .guide-button,
          .news-block {
            max-width: calc(100vw - 48px); /* 视口宽度减去总边距 */
            box-sizing: border-box;
          }
        }

        /* ====== 下拉菜单样式 ====== */
        .dropdown {
          position: relative;
          display: inline-block;
        }

        .dropdown-menu {
          position: absolute;
          top: 100%;
          left: 50%;
          transform: translateX(-50%);
          background: rgba(255, 255, 255, 0.1);
          backdrop-filter: blur(8px);
          border: 1px solid rgba(255, 255, 255, 0.2);
          border-radius: 8px;
          padding: 8px 0;
          min-width: 100px;
          width: fit-content;
          max-width: 120px;
          display: none;
          z-index: 1000;
          margin-top: 8px;
        }

        .dropdown-menu::before {
          content: '';
          position: absolute;
          top: -20px;
          left: 0;
          right: 0;
          height: 20px;
          background: transparent;
        }

        .dropdown-menu a {
          color: #fff;
          padding: 8px 12px;
          margin: 0 4px;
          display: block;
          text-decoration: none;
          text-align: center;
          white-space: nowrap;
          border-radius: 4px;
          transition: background-color 0.3s ease;
        }

        .dropdown-menu a:hover {
          background: rgba(255, 255, 255, 0.2);
        }

        .dropdown:hover .dropdown-menu {
          display: block;
        }

        .dropdown-trigger {
          display: flex;
          align-items: center;
          gap: 4px;
          padding: 8px 12px;
          color: #fff;
          text-decoration: none;
          transition: color 0.3s ease;
        }

        .arrow-down {
          border: solid #fff;
          border-width: 0 2px 2px 0;
          display: inline-block;
          padding: 3px;
          transform: rotate(45deg);
          margin-top: -2px;
        }

        .close-button {
          position: absolute;
          top: 20px;
          right: 20px;
          width: 32px;
          height: 32px;
          background: none;
          border: none;
          cursor: pointer;
          z-index: 1002;
          padding: 0;
          display: flex;
          align-items: center;
          justify-content: center;
          transition: transform 0.3s ease;
        }

        .close-button:hover {
          transform: rotate(90deg);
        }

        .close-button span {
          position: absolute;
          width: 24px;
          height: 2px;
          background-color: #fff;
          border-radius: 2px;
          transition: all 0.3s ease;
        }

        .close-button span:first-child {
          transform: rotate(45deg);
        }

        .close-button span:last-child {
          transform: rotate(-45deg);
        }

        .close-button:hover span {
          background-color: #1890ff;
          box-shadow: 0 0 8px rgba(24, 144, 255, 0.5);
        }

        .sidebar {
          .sidebar-top {
            padding-top: 60px;
          }
        }

        @media (max-width: 768px) {
          /* 快速通道移动端样式 */
          .quick-links {
            padding: 40px 0;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
          }

          .section-title {
            text-align: center;
            margin-bottom: 20px;
            width: 90%;
            max-width: 320px; /* 与卡片宽度一致 */
          }

          .quick-links-grid {
            grid-template-columns: 1fr;
            width: 90%;
            max-width: 320px; /* 与标题宽度一致 */
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 20px;
          }

          .quick-link-card {
            width: 100%;
            margin: 0;
            transform: none; /* 移除缩放 */
          }

          /* ... 其他移动端样式保持不变 ... */
        }

        .process-step {
          display: flex;
          flex-direction: column;
          align-items: center;
          position: relative;
          margin-bottom: 20px;
        }

        .process-dot {
          width: 40px;
          height: 40px;
          border-radius: 50%;
          border: 2px dashed #dc3545;
          display: flex;
          align-items: center;
          justify-content: center;
          margin: 0 auto;
          position: relative;
          z-index: 2;
        }

        .process-dot::before {
          content: '';
          width: 20px;
          height: 20px;
          border-radius: 50%;
          background-color: #dc3545;
          position: absolute;
        }

        .process-line {
          width: 2px;
          height: 40px;
          background-color: #dc3545;
          margin: 10px auto;
        }

        .process-text {
          text-align: center;
          margin-top: 10px;
          width: 100%;
        }

        .process-step:nth-child(3) .process-dot {
          margin: 0 auto;
          transform: translateX(0);
        }

        /* 基础样式 */
        .animate-section {
          opacity: 0;
          transform: translateY(30px);
          transition: all 0.8s ease-out;
        }

        /* 入场动画样式 */
        .animate-section.animate-in {
          opacity: 1;
          transform: translateY(0);
        }

        /* 为不同板块添加延迟 */
        .quick-links {
          transition-delay: 0.2s;
        }

        .recruitment-guide {
          transition-delay: 0.4s;
        }

        /* 确保动画只在非移动端触发 */
        @media (max-width: 768px) {
          .animate-section {
            opacity: 1;
            transform: none;
            transition: none;
          }
        }
      `}</style>
    </div>
  );
};

export default PublicRecruitmentPage; 